package com.appspot.niehonglei.action;

import javax.jdo.PersistenceManager;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.appspot.niehonglei.dao.PMF;
import com.appspot.niehonglei.jdo.Index;

public class DeleteIndex  implements ActionInterface {

	@Override
	public void execute(HttpServletRequest request, HttpServletResponse response) {
		String id = request.getParameter("id");
		try{
			if (id != null) {
				PersistenceManager pm = PMF.get().getPersistenceManager();
				Index index = pm.getObjectById(Index.class,Long.valueOf(id));
				pm.deletePersistent(index);
				pm.close();
				
			}
			response.sendRedirect("/publish?new");
		}catch(Exception e){
			e.printStackTrace();
		}
	}

}
